package com.neuedu.his.controller;

import com.neuedu.his.po.Register;
import com.neuedu.his.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/register")
public class RegisterController {

    @Autowired
    private RegisterService registerService;

    // 新增挂号记录
    @PostMapping("/add")
    public Map<String, Object> addNewReg(@RequestBody Register register) {
        Map<String, Object> result = new HashMap<>();
        try {
            registerService.addNewReg(register);
            result.put("code", 200);
            result.put("message", "挂号成功");
        } catch (Exception e) {
            result.put("code", 500);
            result.put("message", "挂号失败：" + e.getMessage());
        }
        return result;
    }
}